package datatypes;

import exceptions.MCUnknownElementException;

public enum MCItem {
	
	UNKNOWN					(-1),
	
	//Items that can take damage but can not be enchanted
	FLINT_AND_STEEL 		(0x103, true, false),
	BOW 					(0x105, true, false),
	FISHING_ROD				(0x15a, true, false),
	SHEARS					(0x167, true, false),
	
	//TOOLS
		//WOOD
		SWORD_WOOD			(0x10c, true),
		SHOVEL_WOOD			(0x10d, true),
		PICKAXE_WOOD		(0x10e, true),
		AXE_WOOD			(0x10f, true),
		HOE_WOOD			(0x122, true),
		
		//STONE
		SWORD_STONE			(0x110, true),
		SHOVEL_STONE		(0x111, true),
		PICKAXE_STONE		(0x112, true),
		AXE_STONE			(0x113, true),
		HOE_STONE			(0x123, true),
		
		//IRON
		SWORD_IRON			(0x10b, true),
		SHOVEL_IRON			(0x100, true),
		PICKAXE_IRON		(0x101, true),
		AXE_IRON			(0x102, true),
		HOE_IRON			(0x124, true),
		
		//DIAMOND
		SWORD_DIAMOND		(0x114, true),
		SHOVEL_DIAMOND		(0x115, true),
		PICKAXE_DIAMOND		(0x116, true),
		AXE_DIAMOND			(0x117, true),
		HOE_DIAMOND			(0x125, true),
		
		//GOLD
		SWORD_GOLD			(0x11b, true),
		SHOVEL_GOLD			(0x11c, true),
		PICKAXE_GOLD		(0x11d, true),
		AXE_GOLD			(0x11e, true),
		HOE_GOLD			(0x126, true),
	
	
	//ARMOUR
		//LEATHER
		HELMET_LEATHER		(0x12a, true),
		CHESTPLATE_LEATHER	(0x12b, true),
		LEGGINGS_LEATHER	(0x12c, true),
		BOOTS_LEATHER		(0x12d, true),

		//CHAIN
		HELMET_CHAIN		(0x12e, true),
		CHESTPLATE_CHAIN	(0x12f, true),
		LEGGINGS_CHAIN		(0x130, true),
		BOOTS_CHAIN			(0x131, true),
		
		//IRON
		HELMET_IRON			(0x132, true),
		CHESTPLATE_IRON		(0x133, true),
		LEGGINGS_IRON		(0x134, true),
		BOOTS_IRON			(0x135, true),

		//DIAMOND
		HELMET_DIAMOND		(0x136, true),
		CHESTPLATE_DIAMOND	(0x137, true),
		LEGGINGS_DIAMOND	(0x138, true),
		BOOTS_DIAMOND		(0x139, true),
		
		//GOLD
		HELMET_GOLD			(0x13a, true),
		CHESTPLATE_GOLD		(0x13b, true),
		LEGGINGS_GOLD		(0x13c, true),
		BOOTS_GOLD			(0x13d, true);
	
	

	
	private int id;
	private boolean damage;
	private boolean enchantable;
	
	MCItem(int id) {
		this.id = id;
		this.damage = false;
		this.enchantable = false;

	}

	
	MCItem(int id, boolean damageable) {
		this.id = id;
		this.damage = damageable;
		this.enchantable = true;
	}
	
	
	MCItem(int id, boolean damageable, boolean enchantable) {
		this.id = id;
		this.damage = damageable;
		this.enchantable = enchantable;
	}
	
	public short getItemId() {
		return (short) id;
	}
	
	public boolean canTakeDamage() {
		return damage;
	}

	public boolean isEnchantable() {
		return enchantable;
	}
	
	
	public static MCItem getObject(int itemid) throws MCUnknownElementException {
		for(MCItem item : values()) {
			if(item.id == itemid) {
				return item;
			}
		}
		
		throw new MCUnknownElementException();
	}
	
}
